home *** CD-ROM | disk | FTP | other *** search
-
- package sub_arctic.constraints;
-
- import sub_arctic.lib.interactor_consts;
- import sub_arctic.lib.interactor;
-
- /**
- * Class to provide a non-standard object/part encoding. Unlike standard
- * references, these may refer to arbitrary objects and not just the local
- * neighborhood. Either non-standard (given by a part number) or standard
- * parts (given by one of the standard part codes plus an orientation value)
- * may be used with the reference.<p>
- *
- * Methods are provided for creating a new instance from an existing instance
- * by filling in the part portion only. This allows a cleaner notation
- * (i.e., EXT.OBJ(other).W()).<p>
- *
- * @author Scott Hudson
- */
-
- public class ext_objpart_encoding implements std_encoding_consts {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Indication of whether the referenced part is one of the standard ones
- * (i.e,. x, y, x2, y2, w, h, center, visible, part_a, or part_b). This
- * controls the interpretation of the ref_part field. For standard parts
- * this field contains a part encoding (and the orientation field is
- * employed). For non-standard parts, ref_part contains a part number
- * (and the orientation field is ignored). */
- protected boolean _uses_std_part;
-
- /** Indication of whether the referenced part is one of the standard ones
- * (i.e,. x, y, x2, y2, w, h, center, visible, part_a, or part_b). This
- * controls the interpretation of the ref_part field. For standard parts
- * this field contains a part encoding (and the orientation field is
- * employed). For non-standard parts, ref_part contains a part number
- * (and the orientation field is ignored). */
- public boolean uses_std_part() {return _uses_std_part;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** The object being referenced. */
- protected interactor _ref_obj;
-
- /** The object being referenced. */
- public interactor ref_obj() {return _ref_obj;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** The orientation of this part. This should be one of the values:
- * std_encoding_consts.HORIZONTAL, std_encoding_consts.VERTICAL, or
- * std_encoding_consts.NOT_ORIENTED. This is used only for standard part
- * references (which care about the orientation), and is ignored for
- * non-standard references. */
- protected int _orientation;
-
- /** The orientation of this part. This should be one of the values:
- * std_encoding_consts.HORIZONTAL, std_encoding_consts.VERTICAL, or
- * std_encoding_consts.NOT_ORIENTED. This is used only for standard part
- * references (which care about the orientation), and is ignored for
- * non-standard references. */
- public int orientation() {return _orientation;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Encoding of the referenced part. If uses_std_part is true, then this
- * contains a 3 bit standard part encoding (which is supplemented by the
- * orientation field). If uses_std_part is false, then this contains a
- * full part number (and the orientation field is ignored). */
- protected int _ref_part;
-
- /** Encoding of the referenced part. If uses_std_part is true, then this
- * contains a 3 bit standard part encoding (which is supplemented by the
- * orientation field). If uses_std_part is false, then this contains a
- * full part number (and the orientation field is ignored). */
- public int ref_part() {return _ref_part;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Constructor for a non-local reference to a standard part.
- *
- * @param interactor obj object being referenced.
- * @param int part_code value for part encoding. This must be between
- * zero and PARTCODE_MAX. Values outside this range
- * will be silently truncated.
- * @param int orient_code code for the orientation of this part. Should be
- * one of HORIZONTAL, VERTICAL, or NOT_ORIENTED
- */
- public ext_objpart_encoding(interactor obj, int part_code, int orient_code)
- {
- _uses_std_part = true;
- _orientation = orient_code;
- _ref_obj = obj;
- _ref_part = (part_code & PARTCODE_MASK) << PARTCODE_SHIFT;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Constructor for a non-local reference to a non-standard part.
- *
- * @param interactor obj object being referenced.
- * @param int part_number part number for non-standard part being referenced.
- * Note: the PARTCODE_* values should <b>NOT</b> be
- * used for this parameter.
- */
- public ext_objpart_encoding(interactor obj, int part_number)
- {
- _uses_std_part = false;
- _orientation = 0;
- _ref_obj = obj;
- _ref_part = part_number;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the x part of this object */
- public ext_objpart_encoding X()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_XY, HORIZONTAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the x part of this object.
- * This does exactly the same thing as X(). */
- public ext_objpart_encoding X1()
- {
- return X();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the x part of this object.
- * This does exactly the same thing as X(). */
- public ext_objpart_encoding LEFT()
- {
- return X();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the y part of this object */
- public ext_objpart_encoding Y()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_XY, VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the y part of this object.
- * This does the exactly the same thing as Y(). */
- public ext_objpart_encoding Y1()
- {
- return Y();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the y part of this object.
- * This does the exactly the same thing as Y(). */
- public ext_objpart_encoding TOP()
- {
- return Y();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the x2 part of this object */
- public ext_objpart_encoding X2()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_XY2, HORIZONTAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the x2 part of this object.
- * This is the same as X2(). */
- public ext_objpart_encoding RIGHT()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_XY2, HORIZONTAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the y2 part of this object */
- public ext_objpart_encoding Y2()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_XY2, VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the y2 part of this object.
- * This is the same as Y2(). */
- public ext_objpart_encoding BOTTOM()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_XY2, VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the w part of this object */
- public ext_objpart_encoding W()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_WH, HORIZONTAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the h part of this object */
- public ext_objpart_encoding H()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_WH, VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the horizontal center part of
- * this object */
- public ext_objpart_encoding HCENTER()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_CENTER, HORIZONTAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the vertical center part of
- * this object */
- public ext_objpart_encoding VCENTER()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_CENTER, VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the "visible" part of this
- * object */
- public ext_objpart_encoding VISIBLE()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_VISIBLE,NOT_ORIENTED);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the "enabled" part of this
- * object */
- public ext_objpart_encoding ENABLED()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_ENABLED,NOT_ORIENTED);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the "part_a" part of this
- * object. */
- public ext_objpart_encoding PART_A()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_PART_A,NOT_ORIENTED);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the "part_b" part of this
- * object. */
- public ext_objpart_encoding PART_B()
- {
- return new ext_objpart_encoding(ref_obj(), PARTCODE_PART_B,NOT_ORIENTED);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating an arbitrary part of the object
- * being referenced by this object. */
- public ext_objpart_encoding PART(int part_num)
- {
- return new ext_objpart_encoding(ref_obj(), part_num);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
-
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-